package com.example.a16478095_;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity extends AppCompatActivity {
    Button btn1;
    Button goFirst;
    String username;
    String password;
    EditText et_username;
    EditText et_password;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
       btn1=findViewById(R.id.signUp);
       goFirst=findViewById(R.id.edit_login);
        et_username=findViewById(R.id.edit_username);
        et_password=findViewById(R.id.edit_password);
        btn1.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                Intent i=new Intent(LoginActivity.this, RegisterActivity.class);
               startActivity(i);
            }
        });
        goFirst.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                getEdit();
                if(TextUtils.isEmpty(username)){
                    Toast.makeText(LoginActivity.this,"请输入用户名",Toast.LENGTH_SHORT).show();
                    return;
                }else if(TextUtils.isEmpty(password)) {
                    Toast.makeText(LoginActivity.this, "请输入密码", Toast.LENGTH_SHORT).show();
                    return;
                }else {
                    Intent i=new Intent(LoginActivity.this, orderMenu.class);
                    startActivity(i);
                }

            }
        });
    }
    public void getEdit(){
        username=et_username.getText().toString();
        password=et_password.getText().toString();
    }
}
